package com.tangyh.basic.sign.util;
import lombok.Data;

/**
 * @Author: LiXincheng
 * @Description: 返回给调用方的数据
 * @Date: 2021/11/17 17:50
 */
@Data
public class ResultData<T> {

  /**
   * 数据
   */
  private T data;
  /**
   *
   */
  private String message;
  /**
   * 0:成功  1：异常
   */
  private int code = 0;

  public static ResultData get() {
    return new ResultData();
  }

  public ResultData setData(T data) {
    this.data = data;
    return this;
  }

  public ResultData setMessage(String message) {
    this.message = message;
    return this;
  }

  public ResultData setCode(int code) {
    this.code = code;
    return this;
  }

  /**
   * 逻辑处理是否成功
   *
   * @return 是否成功
   */
  public Boolean getIsSuccess() {
    return this.code == 0;
  }

  public ResultData fail(String message) {
    this.message = message;
    this.code = 1;
    return this;
  }
}
